package com.hnqcgczy.gp.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class MysqlConnection extends IConnection {
    private  static MysqlConnection myConnection=new MysqlConnection();
    public MysqlConnection(){

    }
    private final String URL="jdbc:mysql://localhost:3306/dujiaoshou?useSSL=false&serverTimezone=Hongkong&characterEncoding=utf-8&autoReconnect=true";
    private final String USER="root";
    private final String PW="123456";

    static{
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }


    @Override
    public Connection getConnectionByMysql() throws SQLException {
        Connection coon=DriverManager.getConnection(URL,USER,PW);
        return coon;
    }

    @Override
    public Connection getConnectionByOracle() throws SQLException {
        return null;
    }

    public static void main(String[] args) {
        MysqlConnection myConnection = new MysqlConnection();
        try {
            Connection connectionByMysql = myConnection.getConnectionByMysql();
            System.out.println(connectionByMysql.isClosed());
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

    }
}